<?php


include("config.php");

session_start();
$user_id = $_POST['myusername'];
$event_id = $_POST['event_id'];

$insert_result = mysql_query("insert into user_event value('','$user_id','$event_id')") or die("DB insert error");


$sql="select * from user_event eu,events e where  eu.username = '$user_id' and e.start_date >= now() group by e.event_name";
$result=mysql_query($sql);

$rows = array();
while($r = mysql_fetch_assoc($result)) {
  $rows[] = $r;
}

echo json_encode($rows);

?>

